/**
 * Copyright (c) 2008, George Taylor
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are permitted 
 * provided that the following conditions are met:
 * 
 *   * Redistributions of source code must retain the above copyright notice, this list of 
 *     conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright notice, this list of 
 *     conditions and the following disclaimer in the documentation and/or other materials 
 *     provided with the distribution.
 *   * Neither the name of the copyright holder's organization nor the names of its contributors 
 *     may be used to endorse or promote products derived from this software without specific 
 *     prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package uk.co.taylorconsulting.annoweb.web.builder;

import java.math.BigDecimal;

import org.apache.commons.fileupload.FileItem;

public enum MethodTypeEnum {
	String(String.class, "getString", "null"), primativeByte(byte.class, "getPByte", "-1"), Byte(Byte.class, "getByte", "null"), primativeShort(short.class, "getPShort", "-1"), Short(Short.class, "getShort", "null"), primativeInt(
	        int.class, "getInt", "-1"), Integer(Integer.class, "getInteger", "null"), primativeLong(long.class, "getPLong", "-1"), Long(Long.class, "getLong", "null"), primativeFloat(float.class, "getPFloat", "-1.0"), Float(Float.class,
	        "getFloat", "null"), primativeDouble(double.class, "getPDouble", "-1.0"), Double(Double.class, "getDouble", "null"), primativeBoolean(boolean.class, "getPBoolean", "false"), Boolean(Boolean.class, "getBoolean", "null"), BigDecimal(
	        BigDecimal.class, "getBigDecimal", "null"), primativeChar(char.class, "getPChar", "' '"), Char(Character.class, "getCharacter", "null"), StringA(String[].class, "getStringA", "null"), primativeByteA(byte[].class, "getPByteA",
	        "-1"), ByteA(Byte[].class, "getByteA", "null"), primativeShortA(short[].class, "getPShortA", "-1"), ShortA(Short[].class, "getShortA", "null"), primativeIntA(int[].class, "getIntA", "-1"), IntegerA(Integer[].class,
	        "getIntegerA", "null"), primativeLongA(long[].class, "getPLongA", "-1"), LongA(Long[].class, "getLongA", "null"), primativeFloatA(float[].class, "getPFloatA", "-1.0"), FloatA(Float[].class, "getFloatA", "null"), primativeDoubleA(
	        double[].class, "getPDoubleA", "-1.0"), DoubleA(Double[].class, "getDoubleA", "null"), primativeBooleanA(boolean[].class, "getPBooleanA", "false"), BooleanA(Boolean[].class, "getBooleanA", "null"), primativeCharA(char[].class,
	        "getPCharA", "'\u0000'"), CharA(Character[].class, "getCharacterA", "null"), BigDecimalA(BigDecimal[].class, "getBigDecimalA", "null"), FileItem(FileItem.class, "getFileItem", "null"), FileItemA(FileItem[].class,
	        "getFileItemA", "null");
	private Class<?> clazz;
	private String   method;
	private String   defaultValue;
	
	public String getDefaultValue() {
		return defaultValue;
	}
	
	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}
	
	public Class<?> getClazz() {
		return clazz;
	}
	
	public void setClazz(Class<?> clazz) {
		this.clazz = clazz;
	}
	
	public String getMethod() {
		return method;
	}
	
	public void setMethod(String method) {
		this.method = method;
	}
	
	private MethodTypeEnum(Class<?> clazz, String method, String defaultValue) {
		this.method = method;
		this.clazz = clazz;
		this.defaultValue = defaultValue;
	}
	
	public static MethodTypeEnum getByClass(Class<?> clazz) {
		for (MethodTypeEnum o : MethodTypeEnum.values()) {
			if (o.getClazz() == clazz) {
				return o;
			}
		}
		return null;
	}
}
